/*
	Copyright (C) 2008 by Jean-François Geyelin
	jfgeyelin@gmail.com

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the
	Free Software Foundation, Inc.,
	51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/


#include "all.h"
#include "globals.h"


bool pathIsCorrect(std::string s) {
    FILE *f=fopen((s+"maps/list_of_the_maps.txt").c_str(),"r");
    if (f!=NULL) {
            fclose(f);
            return true;
    }
    return false;

}

bool findPath(void) {
    //FILE *f;
    std::string list[10] = {"KM.app/","KM.app/Content/","KM.app/Content/data/","data/","","../","../../","../../../","../../../../","../../../../../"};
    int i;
    for (i=0;i<10;i++) {
            if (pathIsCorrect(list[i])) {
                relativePath = list[i];
                return true;
            }
    }
    LOG_ERROR("could not find path to data files.\n");
    return false;
}



